Skip to content

fix: ensure styles are loaded in dev mode for routes containing special characters#9894

Merged
Rich-Harris merged 5 commits intosveltejs:masterfrom
whataboutpereira:decode-pathname-fix
May 17, 2023
Merged

fix: ensure styles are loaded in dev mode for routes containing special characters#9894
Rich-Harris merged 5 commits intosveltejs:masterfrom
whataboutpereira:decode-pathname-fix

Conversation

@whataboutpereira
Copy link
Contributor

SvelteKit doesn't decode special characters in pathnames when loading CSS modules in dev mode, resulting in an error:

Internal server error: Failed to load url /src/routes/(special)/hinnap%C3%A4ring/+page.svelte?svelte=&type=style&lang.css=&inline= (resolved id: /src/routes/(special)/hinnap%C3%A4ring/+page.svelte?svelte&type=style&lang.css). Does the file exist?

Actual path:

/src/routes/(special)/hinnapäring/

Fix by using decodeURI on the url.pathname when loading CSS modules.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@changeset-bot
Copy link

changeset-bot bot commented May 10, 2023

🦋 Changeset detected

Latest commit: cea820e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

SvelteKit doesn't decode special characters in pathnames when loading CSS modules in dev mode, resulting in an error:

Internal server error: Failed to load url /src/routes/(special)/hinnap%C3%A4ring/+page.svelte?svelte=&type=style&lang.css=&inline= (resolved id: /src/routes/(special)/hinnap%C3%A4ring/+page.svelte?svelte&type=style&lang.css). Does the file exist?

Actual path:

/src/routes/(special)/hinnapäring/

Fix by using decodeURI on the url.pathname when loading CSS modules.
@benmccann benmccann changed the title Fix loading styles for routes containing special characters in dev mode. fix: ensure styles are loaded in dev mode for routes containing special characters May 11, 2023
@Rich-Harris
Copy link
Member

Thank you. This would benefit from a test, are you able to add one?

@whataboutpereira
Copy link
Contributor Author

Thank you. This would benefit from a test, are you able to add one?

I did think about that, but unfortunately I wouldn't know where to begin.

@Rich-Harris
Copy link
Member

I added a test in cea820e

@Rich-Harris Rich-Harris merged commit a2f23ca into sveltejs:master May 17, 2023
@github-actions github-actions bot mentioned this pull request May 17, 2023
@whataboutpereira
Copy link
Contributor Author

I added a test in cea820e

Wonderful, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants